from array import array

import numpy as np
import pandas as pd

# array = np.array([1, 2, 3])
#
# np.array([[1,2,3],[4,5,6],[7,8,9]]) # 多维数组
#
# print(array)  # array里面的数据 [1 2 3]
# print(array.shape)  # array里面有3个数据 (3,)
# print(array.size)  # array的长度 3
#
# # 访问数据
# print("第一行数据: %s",array[1]) # 2

# Series
# array = np.array([1, 2, 3])
# indexABC = ['a','b','c']
# series = pd.Series(array, index=indexABC)
# print(series)
# print("series中第一个的元素:",series[0])
# print("series中index为c的元素:",series['c'])

# DataFrame
np_array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

# 行
row_index = ['row1', 'row2', 'row3']

# 列
col_name = ['col1', 'col2', 'col3']

data_frame = pd.DataFrame(data=np_array, index=row_index, columns=col_name)

print(data_frame)
print("\n访问col3数据")
print(data_frame['col3'])
